import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import "normalize.css"
import "@/assets/css/common.scss"
Vue.config.productionTip = false

//导入骨架屏组件
import skeleton from "./utils/SkeletonView.vue"
Vue.component('skeleton', skeleton)

//提示窗
import MessageBox from './components/shop/index'
Vue.prototype.$Message = MessageBox

import Message from './components/popup/index'
Vue.prototype.$msg = Message


import defaultImg from '@/assets/img/兔子.png'
//设置全局自定义指令
Vue.directive("lazy", (el, binding) => {
  {
    const observer = new IntersectionObserver(([{ isIntersecting }]) => {
      if (isIntersecting) {
        observer.unobserve(el)
        el.src = binding.value
        //图片加载失败 钩子函数 onerror js自带的
        el.onerror = () => {
          el.src = defaultImg
        }
      }
    })
    observer.observe(el)
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
